package com.mrobuy.jdvc.dao.impl;

import com.mrobuy.jdvc.dao.VCCateSalePropDao;
import com.mrobuy.jdvc.dao.VCExtPropValueDao;
import com.mrobuy.jdvc.entity.VCCategorySaleProp;
import com.mrobuy.jdvc.entity.VCExtPropValue;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

import java.util.Collections;
import java.util.List;

@Repository("vcExtPropValueDao")
public class VCExtPropValueDaoImpl implements VCExtPropValueDao {

    private static Logger LOG = LoggerFactory.getLogger(VCExtPropValueDao.class);

    @Autowired
    private JdbcTemplate jdbcTemplate;

    @Override
    public List<VCExtPropValue> load(String propid) {
        StringBuilder sql = new StringBuilder();
        sql.append(" SELECT * from VC_EXTPROP_VALUE where PROPID = ?  order by SORT ");
        try {
            List<VCExtPropValue> list = jdbcTemplate.query(sql.toString(), new Object[]{propid}, new BeanPropertyRowMapper(VCExtPropValue.class));
            return list;
        } catch (Exception e) {
            LOG.error(e.getMessage());
        }

        return Collections.EMPTY_LIST;
    }
}
